package educationaladministrationsystem.CSM.Mapper.StudentAndTeacher.Student;

import educationaladministrationsystem.Class.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentElectiveCourseMapper {
    @Select("select * from course limit #{page},#{pageNumber}")
    List<Course> getAllCourse(int page, int pageNumber);

    @Select("select count(*) from course")
    int getAllCourseCount();

    @Insert("insert into studentwithcourse values (#{UID},#{classId},null,null)")
    void addNewCourse(String UID, String classId);

    @Select("select peopleSum,peopleNumber from course where id=#{classId}")
    Map<Integer, Integer> peopleNumAndSum(String classId);

    @Update("update course set peopleNumber=#{num} where id=#{id}")
    void updateCoursePeopleNumber(int num, String id);

    @Delete("delete from studentwithcourse where studentId=#{UID} and classId=#{classId}")
    void deleteCourse(String UID, String classId);

    @Select("select classId from studentwithcourse where studentId=#{id}")
    List<String> getHaveSelectCourse(String id);

    @Select("select degreeId from student where id=#{id}")
    int getDegree(String id);

    @Select("select degreeDemand from course where id=#{id}")
    String getCourseDegreeDemand(String id);
}
